<template>
<el-container class="home-container">
     <el-header>
         <div>
             <img src="../assets/images/zq1.jpg" alt="">
              <span>和兴体育馆管理信息系统</span>
         </div>

<el-dropdown size="small" split-button type="primary" >
     欢迎{{ this.logName }}登录
<!--     欢迎{{ }}登录-->
  <el-dropdown-menu slot="dropdown">
    <!-- <el-dropdown-item>个人信息</el-dropdown-item> -->
    <el-dropdown-item ><a href="/">系统登出</a></el-dropdown-item>
  </el-dropdown-menu>
</el-dropdown>
     </el-header>
     <el-container>
     <el-aside :width="isCollapse?'64px':'220px' ">
         <div class="toggle-button" @click="toggleCollapse">
             |||
         </div>
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            unique-opened
            :collapse-transition="false"
            :collapse="isCollapse"
            router>
            <el-submenu :index="''+index+1" v-for="(v,index) in menuList" :key="index">
                <template slot="title">
                <i :class="v.icon" style="color:white"></i>
                <span>{{v.menuName}}</span>
                </template>

             <el-menu-item :index="'/'+subV.url" v-for="(subV,subIndex) in v.subMenuList" :key="subIndex">
                <i :class="subV.icon"  style="color:white"></i>
                <span >{{subV.menuName}}</span>
            </el-menu-item>
            </el-submenu>

            </el-menu>
     </el-aside>

     <el-main>
         <router-view/>
     </el-main>
     </el-container>
</el-container>
</template>
<script>

export default {
    name:"Home",
    data(){
        return{
           isCollapse:false,
           menuList:[],
           logName: null
        }
    },
    methods:{
        toggleCollapse(){
           this.isCollapse=!this.isCollapse
        },

      getMenuList(){
          var parse = JSON.parse(sessionStorage.getItem("user"));
          console.log(parse,'?????????');
          this.logName = parse.data.workName;
          let roleId=parse.data.roleId;
          this.$axios.post('/menu-info/getMenuList','roleId='+roleId).then(res=>{
                console.log(res)
                this.menuList=res.data.data
            }).catch(err=>{
                console.log(err)
            })
        },
    },
    created(){
        this.getMenuList();
    }
}
</script>
<style scoped>
.home-container{
    height: 100%;
}
.el-header{
    /*background-color: rgb(26, 145, 255);*/
    background-color: #cb0e0e;
    display:flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-size: 25px;
}
.el-header div{
    display: flex;
    align-items: center;
}
.el-header img{
    width: 50px;
    height: 50px;
    opacity: 0.4;
    border-radius: 90px;
    margin-right: 10px;
}
.el-dropdown{
    opacity: 1;
}
.el-aside{
    background-color: rgb(36, 46, 52);
}
.el-aside .el-menu{
    border-right:none ;
}
.toggle-button{
    background-color:  rgb(26, 145, 255);
    color: white;
    text-align: center;
    line-height: 20px;
    font-size: 10px;
    cursor: pointer;
    letter-spacing: 0.3em;
}
.el-main{
    background-color: rgb(255, 255, 255);
}
</style>
